home *** CD-ROM | disk | FTP | other *** search
- #include "../CGVPMacro.csi"
-
- AutoEnumTC
-
- MainInput
- {
- uniform sampler2D shadMap0 : register(sn),
- #if %TEMP_SHAD_SAMPLEMASK1
- uniform sampler2D shadMap1 : register(sn),
- #endif
- #if %TEMP_SHAD_SAMPLEMASK2
- uniform sampler2D shadMap2 : register(sn),
- #endif
- uniform sampler2D baseMap : register(sn),
- uniform float4 Ambient,
- uniform float4 Fading,
- #if %ENVCMAMB
- uniform float4 Reflect,
- uniform samplerCUBE envMap : register(sn),
- #endif
- }
- DeclarationsScript
- {
- // define outputs from vertex shader
- struct vertout
- {
- float4 HPosition : POSITION;
- float4 shadTC0 : TEXCOORDN;
- #if %TEMP_SHAD_SAMPLEMASK1
- float4 shadTC1 : TEXCOORDN;
- #endif
- #if %TEMP_SHAD_SAMPLEMASK2
- float4 shadTC2 : TEXCOORDN;
- #endif
- float4 baseTC : TEXCOORDN;
-
- #if %TEMP_MIXED_MAP
- float4 depthTC0 : TEXCOORDN;
- #if %TEMP_SHAD_SAMPLEMASK2
- float4 depthTC1 : TEXCOORDN;
- #endif
- #endif
-
- #if %ENVLIGHT
- float4 Color : COLOR0;
- #elif %ENVCMAMB
- float4 envTC : TEXCOORDN;
- #endif
- };
-
- FOUT
- }
- CoreScript
- {
- float3 shad = (float3)0;
- float3 compare = (float3)0;
-
- // load the decal
- float4 decalColor = tex2D(baseMap, IN.baseTC.xy);
- // load the 3 shadow samples
- float4 shadColor0 = tex2Dproj(shadMap0, IN.shadTC0.xyzw);
- shad.x = shadColor0.r/8 + shadColor0.g;
- #if %TEMP_SHAD_SAMPLEMASK1
- float4 shadColor1 = tex2Dproj(shadMap1, IN.shadTC1.xyzw);
- shad.y = shadColor1.r/8 + shadColor1.g;
- #endif
- #if %TEMP_SHAD_SAMPLEMASK2
- float4 shadColor2 = tex2Dproj(shadMap2, IN.shadTC2.xyzw);
- shad.z = shadColor2.r/8 + shadColor2.g;
- #endif
- #if %TEMP_DEPTH_MAP
- // Using NVidia Depth textures
- compare.x = 1-shadowColor0.b;
- #if %TEMP_SHAD_SAMPLEMASK1
- compare.y = 1-shadowColor1.b;
- #endif
- #if %TEMP_SHAD_SAMPLEMASK2
- compare.z = 1-shadowColor2.b;
- #endif
- compare.xyz = vShadow.xyz * Fading.xyz;
- #elif %TEMP_MIXED_MAP
- // Using PS2.0 Z-Comparing (mixed 2D/Depth technique)
- float3 vZ = (float3)0;
- vZ.x = IN.depthTC0.x / IN.depthTC0.y;
- #if %TEMP_SHAD_SAMPLEMASK1
- vZ.y = IN.depthTC0.z / IN.depthTC0.w;
- #endif
- #if %TEMP_SHAD_SAMPLEMASK2
- vZ.z = IN.depthTC1.x / IN.depthTC1.y;
- #endif
- shad = shad - vZ;
- compare = step(shad, float3(0.0, 0.0, 0.0));
- compare.xyz = compare.xyz * Fading.xyz;
- compare.x = compare.x * shadColor0.a;
- #if %TEMP_SHAD_SAMPLEMASK1
- compare.y = compare.y * shadColor1.a;
- #endif
- #if %TEMP_SHAD_SAMPLEMASK2
- compare.z = compare.z * shadColor2.a;
- #endif
- #else
- // Using 2D shadow maps (simplest technique)
- compare.x = shadowColor0.a;
- #if %TEMP_SHAD_SAMPLEMASK1
- compare.y = shadowColor1.a;
- #endif
- #if %TEMP_SHAD_SAMPLEMASK2
- compare.z = shadowColor2.a;
- #endif
- compare.xyz = compare.xyz * Fading.xyz;
- #endif
-
- float fCompare = dot(compare, float3(1, 1, 1));
- #if %ENVLIGHT
- half3 amb = decalColor.xyz * IN.Color.xyz;
- #elif %ENVCMAMB
- // load the environment map
- half4 envColor = texCUBE(envMap, IN.envTC.xyz);
- half3 amb = lerp(decalColor.xyz*Ambient.xyz, envColor.xyz, Reflect.a);
- #else
- half3 amb = decalColor.xyz * Ambient.xyz;
- #endif
- OUT.Color.xyz = amb.xyz;
- OUT.Color.a = fCompare;
- }
-
-